{include file="public/layout" /}
<body style="overflow: auto; cursor: default; -moz-user-select: inherit;background-color:#F4F4F4;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="shop/left" /}
<div id="geduan_div" class="h10"></div>
<div id="page_div" class="page min-hg-c mb-20" style="min-width: auto;box-shadow: none;">
    <div class="ncap-form-default flexigrid htitx pt0">
        <div class="fixed-bar">
            <div class="item-title">
                <a class="back_xin" href="javascript:history.back();" title="返回"><i class="iconfont e-fanhui"></i></a>
                <div class="subject"><h3>添加提货点</h3> <h5></h5></div>
            </div>
        </div>

        <form class="form-horizontal" id="postForm">
            <dl class="row">
                <dt class="tit"><label for="title"><em>*</em>提货点名称</label></dt>
                <dd class="opt"><input autocomplete="off" id="title" name="title" value="" class="input-txt" type="text"/></dd>
            </dl>
            <dl class="row">
                <dt class="tit"><label for="intro">提货点简介</label></dt>
                <dd class="opt"><input autocomplete="off" id="intro" name="intro" value="" class="input-txt" type="text"/></dd>
            </dl>
            <dl class="row">
                <dt class="tit"><label for="phone"><em>*</em>提货点手机号</label></dt>
                <dd class="opt"><input autocomplete="off" id="phone" name="phone" value="" class="input-txt" type="text"/></dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>提货点地址</label>
                </dt>
                <dd class="opt">
                    <select name="province" id="province" onchange="changeRegion(this,1);">
                        <option value="0">请选择</option>
                        {volist name="$province_list" id="vo"}
                        <option value="{$vo.id}">{$vo.name}</option>
                        {/volist}
                    </select>
                    <select name="city" id="city" onchange="changeRegion(this,2);" class="none">
                    </select>
                    <select name="area" id="area" class="none">
                    </select>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>详细地址</label>
                </dt>
                <dd class="opt">
                    <input autocomplete="off" name="address" id="address" value="" class="input-txt" type="text"/>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit"><label for="bussiness_time"><em>*</em>营业时间</label></dt>
                <dd class="opt">
                    <!--<input autocomplete="off" id="bussiness_time" name="bussiness_time" value="" class="input-txt" type="text"/>-->
                    <input type="text" class="txt" id="bussiness_time" name="bussiness_time" placeholder="00:00:00 - 00:00:00">
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit"><label for="logo">提货点logo</label></dt>
                <dd class="opt">
                    <div class="tab-pane pics" id="tab_proimg">
                        <table class="table table-bordered">
                            <tbody>
                            <tr>
                                <td>
                                    <div class="sort-list">
                                        <div class="images_upload" id="logo_div"
                                             style="width: 100px;display: block;">
                                            <div class="ic">
                                                <div class="upimg">
                                                    <div class="icaction" style="display: none;">
                                                        <span class="load_images" id="logo_update"
                                                              onclick="GetUploadify(1, '', 'allimg', 'logo_callback');"><i
                                                                class="iconfont e-bianji2 f-20"></i></span>
                                                    </div>
                                                    <div class="cover-bg" style="display: none;"></div>
                                                    <img id="logo_img" src="__STATIC__/admin/logo/login-logo.png">
                                                    <input type="hidden" name="logo" id="logo" value="">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <a href="javascript:void(0);"
                                       onclick="GetUploadify(1, '', 'allimg', 'logo_callback');"
                                       class="img-upload mb15" title="点击上传" id="logo_a" style="display: none;">
                                        <div class="y-line"></div>
                                        <div class="x-line"></div>
                                    </a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit"><label for="litpic">提货点大图</label></dt>
                <dd class="opt">
                    <div class="tab-pane pics" id="tab_proimg">
                        <table class="table table-bordered">
                            <tbody>
                            <tr>
                                <td>
                                    <div class="sort-list">
                                        <div class="images_upload" id="litpic_div"
                                             style="width: 100px;display: block;">
                                            <div class="ic">
                                                <div class="upimg">
                                                    <div class="icaction" style="display: none;">
                                                        <span class="load_images" id="litpic_update" onclick="GetUploadify(1, '', 'allimg', 'litpic_callback');"><i class="iconfont e-bianji2 f-20"></i></span>
                                                    </div>
                                                    <div class="cover-bg" style="display: none;"></div>
                                                    <img id="litpic_img" src="__STATIC__/admin/logo/login-logo.png">
                                                    <input type="hidden" name="litpic" id="litpic" value="">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <a href="javascript:void(0);"
                                       onclick="GetUploadify(1, '', 'allimg', 'litpic_callback');"
                                       class="img-upload mb15" title="点击上传" id="litpic_a" style="display: none;">
                                        <div class="y-line"></div>
                                        <div class="x-line"></div>
                                    </a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit"><label><em>*</em>位置选择</label></dt>
                <dd class="opt">
                    <input autocomplete="off" type="text" id="point" name="point" value="" class="input-txt"/>
                    <input type="hidden" id="point_hidden" value=""/>
                    <a href="JavaScript:void(0);" onclick="chooseMap();">选择</a>
                </dd>
            </dl>

            <div class="ncap-form-default">
                <div class="bot2" style="left: 115px;">
                    <a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green">确认提交</a>
                    <a class="ncap-btn-big ncap-btn-no" href="javascript:history.back();" title="返回">返回</a>
                </div>
            </div>
        </form>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    $(function() {
        try {
            if (typeof(eval('is_conceal_1649209614')) == "function" && is_conceal_1649209614()) {
                $(".page").css("margin-left", "");
            } else {
                $(".page").css("margin-left", "110px");
            }
        } catch (e) {
        }
    });

    layui.use('laydate', function() {
        var laydate = layui.laydate;

        laydate.render({
            elem: '#bussiness_time'
            ,type: 'time'
            ,range: true
        });
    })

    function checkForm(){
        if ($('#title').val() == '') {
            showErrorMsg('请输入提货点名称');
            $('#title').focus();
            return false;
        }
        if ($('#phone').val() == '') {
            showErrorMsg('请输入提货点手机号');
            $('#phone').focus();
            return false;
        }
        if ($('#province').val() == 0 || $('#province').val() == null) {
            showErrorMsg('请选择省份');
            return false;
        }
        if ($('#city').val()  == 0 || $('#city').val() == null) {
            showErrorMsg('请选择城市');
            return false;
        }
        var area = $('#area').hasClass('none');
        if (!area && ($('#area').val()  == 0 || $('#area').val() == null)) {
            showErrorMsg('请选择区域');
            return false;
        }
        if ($('#address').val() == '') {
            showErrorMsg('请输入详细地址');
            $('#address').focus();
            return false;
        }
        if ($('#bussiness_time').val() == '') {
            showErrorMsg('请输入营业时间');
            $('#bussiness_time').focus();
            return false;
        }
        if ($('#point').val() == '') {
            showErrorMsg('请选择位置');
            $('#point').focus();
            return false;
        }

        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url : "{:url('OrderVerify/drive_add', ['_ajax'=>1])}",
            data : $('#postForm').serialize(),
            dataType : 'json',
            success : function(res){
                layer.closeAll();
                if(res.code == 1){
                    layer.msg(res.msg, {icon: 1, shade: layer_shade, time: 1000}, function(){
                        window.location.href = res.url;
                    });
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    // 获取联动地址
    function changeRegion(t,type){
        var parent_id = parseInt($(t).val());

        if(!parent_id || 0 >= parent_id){
            if (1 == type) {
                $('#city').addClass('none');
                $('#area').addClass('none');
            }else if (2 == type){
                $('#area').addClass('none');
            }
            return false;
        }

        var url = "{:url('Field/ajax_get_region_data')}";
        $.ajax({
            url: url,
            data: {parent_id:parent_id,_ajax:1},
            type:'post',
            dataType:'json',
            success:function(res){
                if (res.region_html) {
                    // 输出下一级栏目选项
                    if (1 == type) {
                        res = '<option value="0">请选择</option>'+ res.region_html;
                        $('#city').empty().html(res);
                        $('#city').removeClass('none');
                        $('#area').addClass('none');
                        $('#area').empty();
                    }else if (2 == type){
                        res = '<option value="0">请选择</option>'+ res.region_html;
                        $('#area').empty().html(res);
                        $('#area').removeClass('none');
                    }
                }
            },
            error : function(e) {
                layer.closeAll();
                layer.alert(e.responseText, {icon: 5});
            }
        });
    }

    function chooseMap() {
        layer.open({
            type: 2,
            title: '选择位置',
            shadeClose: false,
            shade: layer_shade,
            closeBtn: 3,
            area: ['50%', '77%'],
            btn: ['确定','取消'] ,//按钮
            content: "{:url('OrderVerify/map')}",
            yes: function(index, layero){
                var val = $("#point_hidden").val();
                $("#point").val(val);
                layer.closeAll();
            }
        });
    }

    // 鼠标事件，加载查看大图和更新图片
    $(document).ready(function() {
        $("#logo_div .upimg").live('mouseover', function() {
            $(this).find('div.icaction').show();
            $(this).find('div.cover-bg').show();
        }).live('mouseout', function() {
            $(this).find('div.icaction').hide();
            $(this).find('div.cover-bg').hide();
        });

        $("#litpic_div .upimg").live('mouseover', function() {
            $(this).find('div.icaction').show();
            $(this).find('div.cover-bg').show();
        }).live('mouseout', function() {
            $(this).find('div.icaction').hide();
            $(this).find('div.cover-bg').hide();
        });
    });

    // logo回调加载
    function logo_callback(paths) {
        $('#logo_a').hide();
        $('#logo_div').show();
        $('#logo_div #logo').val(paths);
        $('#logo_div #logo_img').attr('src', paths);
        $('#logo_div #logo_update').attr('onclick', "GetUploadify(1, '', 'allimg', 'logo_callback');");
    }

    // 回调加载
    function litpic_callback(paths) {
        $('#litpic_a').hide();
        $('#litpic_div').show();
        $('#litpic_div #litpic').val(paths);
        $('#litpic_div #litpic_img').attr('src', paths);
        $('#litpic_div #litpic_update').attr('onclick', "GetUploadify(1, '', 'allimg', 'litpic_callback');");
    }
    
    try {
        var mt20_1649209614 = sessionStorage.getItem("mt20_1649209614");
        if (mt20_1649209614 == 1) {
            $("#geduan_div").removeClass("h15");
        } else {
            $("#geduan_div").addClass("h15");
        }
    } catch (e) {
    }
</script>